/*
 * =====================================================================================
 *
 *       Filename:  Prototype.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2015年01月26日 21时09分08秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  LiuYi (), swliuyi@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <limits.h>
#include <iostream>
#include  <tr1/memory>

using namespace std;

class Prototype
{
    public:
        virtual Prototype* Clone() = 0;
};

class Resume : public Prototype
{
    private:
        string name;
        string sex;
        string age;
        string timeArea;
        string company;
    public:
        Resume(string n):name(n){}
        void SetPersonalInfo(string s, string a)
        {
            sex = s;
            age = a;
        }
        void SetWorkExperience(string t, string c)
        {
            timeArea = t;
            company = c;
        }
        void Display()
        {
            cout<<name<<" "<<sex<<" "<<age<<" "<<endl;
            cout<<timeArea<<" "<<company<<endl;
        }
        Prototype * Clone()
        {
            Resume * p =  new Resume(*this);
            return static_cast<Prototype*>(p);
        }
};

int main(int argc, char *argv[])
{
    tr1::shared_ptr<Resume> a(new Resume("Ly"));
    a->SetPersonalInfo("man", "24");
    a->SetWorkExperience("2010-2015", "Sony");
    a->Display();

    tr1::shared_ptr<Resume> b(static_cast<Resume*>(a->Clone()));
    b->SetPersonalInfo("man", "24");
    b->SetWorkExperience("2010-2015", "Sony");
    b->Display();
}
